/**
 * 悬浮框 跟随浏览器滑动
 * @param elem
 * @param top
 * @param left
 * @return
 */
plgor.Scroll = function(elem,top,left){ 
//	this.scrollX = 0;
	this.scrollY = 0;
//	this.stepX = 0;
	this.stepY = 0;
	this.elem = elem;
	this.setPosition(top,left);
}

plgor.Scroll.prototype = {
	scroll:function(){
		var scrollTop,scrollLeft;
		if (document.documentElement && document.documentElement.scrollTop){//存在dtd
			scrollTop = document.documentElement.scrollTop;
//			scrollLeft = document.documentElement.scrollLeft;
		}else if (document.body){//不存在dtd
			scrollTop = document.body.scrollTop;
//			scrollLeft = document.body.scrollLeft;
		}else{
				
		}
//		this.stepX = 0.1*(scrollLeft-this.scrollX);
		this.stepY = 0.1*(scrollTop-this.scrollY);
//		if(this.stepX > 0){
//			this.stepX = Math.ceil(this.stepX);
//		} else{
//			this.stepX = Math.floor(this.stepX); 
//		}
		if(this.stepY > 0){
			this.stepY = Math.ceil(this.stepY);
		} else{
			this.stepY = Math.floor(this.stepY); 
		}
//		this.elem.style.left = parseInt(this.elem.style.left)+this.stepX+"px";
		this.elem.style.top = parseInt(this.elem.style.top)+this.stepY+"px";
//		this.scrollX = this.scrollX+this.stepX;
		this.scrollY = this.scrollY+this.stepY; 
	},
	setPosition:function(top,left){
		this.elem.style.top = top ? (top +"px") : (!this.elem.style.top ? 0 +"px": this.elem.style.top);
		this.elem.style.left = left ? (left +"px") : (!this.elem.style.left ? null: this.elem.style.left);
	},
	execute:function(thisName,millisecond){
		setInterval(thisName+".scroll()",millisecond?millisecond:20);
	}
}